package com.xn.app.muying.activity;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.ReXinLv;

import java.util.ArrayList;

/**
 * Created by xinnuo on 2016/9/28.
 */

public class XInLvAdapter extends BaseAdapter {
    Activity mActivity;
    ArrayList<ReXinLv> xinlv;

    public XInLvAdapter(Activity mActivity, ArrayList<ReXinLv> xinlv) {
        this.mActivity = mActivity;
        this.xinlv = xinlv;
    }

    @Override
    public int getCount() {
        return xinlv.size();
    }

    @Override
    public Object getItem(int position) {
        return xinlv.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=mActivity.getLayoutInflater().inflate(R.layout.item_xin_lv_layout,null);
        TextView shijian= (TextView) convertView.findViewById(R.id.xin_lv_shi_jian);
        TextView ping_jun= (TextView) convertView.findViewById(R.id.ping_jun);
        TextView tai_dong= (TextView) convertView.findViewById(R.id.tai_dong_text);
        ImageView img_01= (ImageView) convertView.findViewById(R.id.img_01);
        ReXinLv map=  xinlv.get(position);
        if (map.getMode()==1){
            img_01.setImageResource(R.mipmap.img_0041);
        }else{
            img_01.setImageResource(R.mipmap.img_0042);
        }
        shijian.setText(map.getRecordDate().replace("T"," "));
        ping_jun.setText("平均胎心率 : "+map.getAvarageFHRs());
        tai_dong.setText("胎动数 : "+map.getKeepScore());
        return convertView;
    }


}
